package com.xing.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xing.DTO.ConferenceUserDTO;
import com.xing.Utils.Result;
import com.xing.service.ConferenceUserService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @version 1.0
 * @Author Xing
 * @Date 2024/2/19 1:21
 */
@Slf4j
@RestController
@RequestMapping("ConferenceUser")
public class ConferenceUserController {
    @Autowired
    private ConferenceUserService service;

    @Operation(summary = "搜索")
    @GetMapping("/page")
    public Result Page(@RequestParam Map<String, Object> params) {
        IPage page = service.Page(params);
        return new Result().ok(page);
    }

    @Operation(summary = "加入会议")
    @PostMapping("create")
    public Result create(@RequestBody ConferenceUserDTO dto) throws Exception {
        String code = service.create(dto);
        return new Result().ok(code);
    }

    @Operation(summary = "删除会议记录")
    @DeleteMapping("{id}")
    public Result delete(@PathVariable("id") String id) {
        service.Delete(id);
        return new Result();
    }

    @Operation(summary = "会议记录")
    @GetMapping("record")
    public Result getRecord(@Param("conferenceId") String conferenceId) {
        log.info("ConferenceUser.Page=conferenceId:{}", conferenceId);
        List<ConferenceUserDTO> record = service.getRecord(conferenceId);
        return new Result().ok(record);
    }
}
